package tehMod;

import net.minecraft.src.EntityAIPublic;
import net.minecraft.src.ItemStack;

public class VillagerAIDropoff extends EntityAIPublic {
	public EntityTehVillager villager;
	public boolean returningToChest = false;
	
	public VillagerAIDropoff(EntityTehVillager villager) {
		super();
		this.villager = villager;
	}

	@Override
	public boolean shouldExecute() {
		return (villager.villageChestPos != null && villager.taskReturning);
	}
	
	@Override
	public void updateTask() {
		super.updateTask();
		
		if (!returningToChest) {
			villager.setWaypoint(villager.villageChestPos[0], villager.villageChestPos[1], villager.villageChestPos[2]);
			returningToChest = true;
		}
		
		if (villager.doneWalking()) {
			villager.faceEntity(villager.waypoint, 1.0f, 1.0f);
			villager.inventory.dropAllItems();
			returningToChest = false;
			villager.taskReturning = false;
			villager.taskGathering = true;
		}
	}

}
